/*
 * Copyright (c) 2021. Moses All Right Reserved
 */

package com.moses.design_patterns.template;

/**
 * @author Moses
 * @email shenhuohui@gmail.com
 * @date 2021/4/10 0:40
 */
public abstract class AbstractTemplate {

    private void beforeMethod1(){
        System.out.println("before methodq");
    }

    protected abstract void method1();

    protected abstract void method2();

    protected abstract boolean hookMethod();

    private void afterMethod(){
        System.out.println("after methods");
    }

    public final void templateMethod(){
        beforeMethod1();
        if(hookMethod()) method1();
        method2();
        afterMethod();
    }
}
